﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.Xml;
using System.IO;
using System.Net;
using System.Data.SqlClient;
using System.Xml.Linq;
using System.Data;
using System.Timers;

namespace FBStockTransfer
{
    static class Program
    {
        static void Main(string[] args)
        {

            Config config = new Config();
            Fishbowl Fishbowl = new Fishbowl();
            DataUtility Utility = new DataUtility();
            String key = "";
            config.start();

            ConnectionObject connectionObject = new ConnectionObject();
            connectionObject = config.ReturnConnection();
            key = config.ReturnKey();
           
            string test_stockTransfer = "SELECT distinct transfer_from ,transfer_to,CONVERT(VARCHAR(10), transfer_date, 23) as transfer_date,transfer_receipt_num" +
                                        " FROM transfer_tbl" +
                                        " WHERE transfer_date > '2012-08-01' and transfer_receipt_num not in (select ReceiptNumber from FB_StockTrasnfer_tbl)" +
                                        " GROUP BY  transfer_from,transfer_to,transfer_date,transfer_receipt_num order by transfer_receipt_num asc";
            //string stockTransfer = "SELECT distinct transfer_from ,transfer_to,CONVERT(VARCHAR(10), transfer_date, 23) as transfer_date,transfer_receipt_num" +
            //                          " FROM transfer_tbl" +
            //                          " WHERE  transfer_date >= DATEADD(hh, DATEDIFF(hh,0,dateadd(hh, -1*1, getdate())), 0)"+
            //                          " AND transfer_date <  DATEADD(hh, DATEDIFF(hh,0,dateadd(hh, 0, getdate())), 0) " +
            //                          " GROUP BY  transfer_from,transfer_to,transfer_date,transfer_receipt_num";
            Utility.SaveTransferOrder(test_stockTransfer, connectionObject, key);
            //Console.ReadLine();
        }
    }
}
